//index.js
var app = getApp();
let animationShowHeight = 300;
  // animation.translateY(-350).step() 动画主要时因为这个 他会改变绝对值
Page({
  data:{
    show:true,
        animationData:"",
        showModalStatus:false,
        imageHeight:0,
        imageWidth:0
  },
  imageLoad: function (e) {  
        this.setData({imageHeight:e.detail.height,imageWidth:e.detail.width});  
  },
  showModal: function () {
    this.setData({
      marginTop:"100%"
    })
        // 显示遮罩层
        var animation = wx.createAnimation({
            duration: 200,
            timingFunction: "linear",
            delay: 0
        })
        this.animation = animation
        animation.translateY(animationShowHeight).step()
        this.setData({
            animationData: animation.export(),
            showModalStatus: true
        })
        setTimeout(function () {
            animation.translateY(-350).step()
            this.setData({
                animationData: animation.export()
            })
        }.bind(this),0)//增加秒数会那个啥
    },
    hideModal: function () {
      this.setData({
        marginTop:"180%"
      })
        // 隐藏遮罩层
        var animation = wx.createAnimation({
            duration: 200,
            timingFunction: "linear",
            delay: 0
        })
        this.animation = animation;
        animation.translateY(animationShowHeight).step()
        this.setData({
            animationData: animation.export(),
        })
        setTimeout(function () {
        animation.translateY(10).step()
        this.setData({
            animationData: animation.export(),
            showModalStatus: false
        })
        }.bind(this))
    },
     onShow:function(){
         let that = this;
         wx.getSystemInfo({
            success: function(res) {
                animationShowHeight = res.windowHeight;
            }
        })
     },
 
})